package com.hspedu.newData.dmsxl.动态规划.基础;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-04 
 * @Version: 1.0
 */

public class LC119杨辉三角Ⅱ {

    public List<Integer> getRow(int rowIndex) {


        int[][] dp = new int[rowIndex][rowIndex];

        for (int i = 0; i < rowIndex; i++) {
            for (int j = 0; j <= i; j++) {
                if (j==0){
                    dp[i][j] = 1;
                }else {
                    dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
                }
            }
        }
        // 使用流来转换数组到 List<Integer>
        List<Integer> list = Arrays.stream(dp[rowIndex-1])  // 转换为流
                .boxed()       // 转换为包装类 Integer
                .collect(Collectors.toList());
        return list;
    }

    @Test
    public void test() {
        // 测试代码
        getRow(4);
    }
}
